
import schedule
from pev3.data.DailyCrawler import DailyCrawler
import time
from datetime import datetime

"""
每天下午15:30执行抓取，只有周一到周五才真正执行抓取任务
"""
def crawlDaily():
    dc = DailyCrawler()
    nowDate = datetime.now()
    weekday = nowDate.strftime('%w')

    if 0 < weekday < 6:
        now = nowDate.strftime('%Y-%m-%d')
        dc.crawlIndex(startDate=now, endDate=now)
        dc.crawl(startDate=now, endDate=now)

if __name__ == '__main__':
    schedule.every().day.at("15:30").do(crawlDaily())
    while True:
        schedule.run_pending()
        time.sleep(10)